home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.19990725-20000114
/
000427_news@columbia.edu _Fri Jan 7 19:23:42 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
7KB
Return-Path: <news@columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id TAA25383
for <kermit.misc@watsun.cc.columbia.edu>; Fri, 7 Jan 2000 19:23:42 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id SAA11271
for kermit.misc@watsun.cc.columbia.edu; Fri, 7 Jan 2000 18:53:59 -0500 (EST)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Subject: C-Kermit 7.0 Case Study #01 - Cleaning Out Beta-Test Binaries
Date: 7 Jan 2000 23:53:58 GMT
Organization: Columbia University
Message-ID: <855uam$b04$1@newsmaster.cc.columbia.edu>
To: kermit.misc@columbia.edu
As time permits, we're going to try to show off some of C-Kermit 7.0's
new features in a series of case studies posted here. If you'd like
to post your own stories, feel free -- that's what this newsgroup is
for! Ditto if you'd like to suggest a topic to be presented.
Today's case study shows how C-Kermit 7.0 can be used to clean up after
itself. As those of you who have been following our neverending saga
know, the C-Kermit 7.0 release was preceded by a long series of Alpha
and Beta tests, in each of which we tried to make binaries available for
as many platforms as possible. For example, the Solaris 2.5.1 Intel
test binary names look like:
cku193a03.solaris25-i386-2.5.1 <-- Edit 193 Alpha Test 03
cku195b07.solaris25-i386-2.5.1 <-- Edit 195 Beta Test 07
cku196b11.solaris25-i386-2.5.1 <-- Edit 196 Beta Test 11
And then the final release binary for this platform is called:
cku196.solaris25-i386-2.5.1
Within a few days after release, we had about 170 final binaries (keep
'em coming!), and hundreds more test ones, each binary consuming about
a megabyte of disk space. Before long, our server disk was running out
of space.
Problem: Given about 600 C-Kermit binaries, how to remove test binaries
for builds that have a final release, but preserve test binaries for
the other platforms that we don't yet have final builds for?
Here's how to do it with a Kermit script (the lines are tagged by letters
that are not part of the script):
a. #!/usr/local/bin/kermit +
b. cd /pub/ftp/kermit/bin/
c. space
d. .\%n := \ffiles(ck?196[-.]*,&a)
e. for \%i 1 \%n 1 {
f. .\%f := \&a[\%i]
g. echo \%f...
h. .\%g := \freplace(\%f,196,19[3-6][ab][0-9][0-9]*)
i. .\%m := \ffiles(\%g,&b)
j. if ( > \%m 0 ) {
k. echo { MATCHES: \%g: \%n}
l. for \%j 1 \%m 1 {
m. ; echo { \flpad(\%j,2). \&b[\%j]}
n. delete /verb \&b[\%j]
o. }
p. }
q. }
r. space
s. exit
Here's a line-by-line explanation:
a. This line is used in UNIX to make the script directly executable
from the shell prompt, just like a shell script. For details,
see the ckermit2.txt file, Section 7.19.
b. We set our current directory to the Kermit binaries directory.
c. The SPACE command tells how much disk space is used and free.
d. This line shows a bunch of new stuff. ".\%n := " is a new
way of assigning values to variables, explained in ckermit2.txt
Section 7.9. It means the same as "assign \%n ". There are
several other forms too, each for a different purpose. The value
in this case is whatever is returned by the call to the built-in
function \ffiles(), namely the number of files that matches the
given pattern. This function has been with us for years, but
there are two new things to notice in the argument list. First,
the pattern supports [xy] notation for characters in a set, and
second, the new second argument specifies an array to be loaded
with the names of all matching files, in this case all the
C-Kermit 7.0 final release binaries ("ck" followed by any single
character ('?') followed by "196" followed by either a hypen "-"
or a period ".", followed by other stuff "*").
e. Now we loop through the \%n filenames in the \&a[] array.
f. For ease of notation, we assign the current array element to \%f.
g. Print the current filename.
h. Now we construct a pattern to match all test versions of the same
build. We do this by replacing the '6' of "196" in the original
filename by a pattern that matches '3', '4', '5', or '6' followed
by 'a' (for Alpha) or 'b' (Beta), followed by two digits. For
complete details on Kermit's new pattern-matching syntax, see
Section 4.9 of ckermit2.txt.
i. We set the variable \%m equal to the number of files that matches
this pattern, i.e. the number of test binaries we can delete for
this build.
j. If \%m is greater than 0 we have some test binaries to delete.
Note the enclosing parentheses; these are optional (in this case)
but in more complicated situations they can be used for grouping
and precedence, e.g. in compound Boolean expressions used as IF
and WHILE conditions. Also note the use of IF rather than XIF --
the distinction is no longer necessary. See section 7.20 about
new IF syntax and Boolean expressions.
k. We print the pattern and the number of matches.
l. And we loop through the files whose names matched the pattern.
m. This statemet was used instead of DELETE while debugging but then
was commented out for the real run (you can also use DELETE /SIMULATE
for this purpose).
n. We delete the old test binary "verbosely", i.e. with a message.
Lines o-q are the closing brackets on the various loops and if's.
r. We find out how much space we freed (a lot!).
s. An EXIT command is included; otherwise Kermit issues its prompt
and waits for more commands. Kerbang scripts are typically
terminated by EXIT.
Note that the arrays created by the \ffiles() function did not need to
be declared; they were created dynamically. The array-loading functions
are explained in Section 4.11 and 7.10 of ckermit2.txt.
We run this script simply by typing its name. No need to start Kermit
first; in fact, we never even *see* Kermit.
This is a rather simple script. In fact it could have done more; for
example, removing ALL extraneous files, such as older test binaries for
which newer test binaries exist, but not a final release binary. Tasks
like this are illustrated in some of the file management scripts in the
C-Kermit script library:
http://www.columbia.edu/kermit/ckscripts.html
- Frank